package com.yzy.thread;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class TestThreadLocal {

    private static ThreadLocal<Map<String, String>> local = new ThreadLocal<>();
    private static ThreadLocal<String> local2 = new ThreadLocal<>();

    public static void main(String[] args) {

        /*ThreadPoolExecutor executor = new ThreadPoolExecutor(5, 5, 10, TimeUnit.SECONDS, new LinkedBlockingQueue());
        executor.execute(() -> {
            Map<String, String> map = new HashMap<>();
            local.set(map);
            map.put("A", Thread.currentThread().getName());
            map.put("B", Thread.currentThread().getName() + "BBB");

            Map<String, String> map1 = local.get();
            System.out.println(map1.get("A"));
            System.out.println(map1.get("B"));
        });
        executor.execute(() -> {
            Map<String, String> map = new HashMap<>();
            map.put("A", Thread.currentThread().getName());
            local.set(map);

            Map<String, String> map1 = local.get();
            System.out.println(map1.get("A"));
        });
        executor.execute(() -> {
            Map<String, String> map = new HashMap<>();
            map.put("A", Thread.currentThread().getName());
            local.set(map);

            Map<String, String> map1 = local.get();
            System.out.println(map1.get("A"));
        });
        executor.execute(() -> {
            Map<String, String> map = new HashMap<>();
            map.put("A", Thread.currentThread().getName());
            local.set(map);

            Map<String, String> map1 = local.get();
            System.out.println(map1.get("A"));
        });

        System.out.println(local.get());*/
        System.out.println(Thread.activeCount());
        ThreadUtils.printAllThreadStatus();


    }

}
